import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_button.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_item.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_scrollView.dart';
import '../../view/account_textField_monry_Item.dart';
import 'logic.dart';

class AccountWithdrawAmountPage extends StatefulWidget {
  const AccountWithdrawAmountPage({Key? key}) : super(key: key);

  @override
  State<AccountWithdrawAmountPage> createState() => _AccountWithdrawAmountPageState();
}

class _AccountWithdrawAmountPageState extends State<AccountWithdrawAmountPage> {
  final AccountWithdrawAmountLogic logic = Get.put(AccountWithdrawAmountLogic());
  final FocusNode _focusNode = FocusNode();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "提现"),
      body: HLScrollView(
        nodeList: [_focusNode],
        children: [
          AccountTextfieldMonryItem(
            title: "每天只能提现一次",
            hintText: "可提现金额是${(logic.userInfoLogic.userInfo.wallet ?? 0.00).toStringAsFixed(2)}元",
            buttonText: '提现',
            monry: logic.userInfoLogic.userInfo.wallet ?? 0.00,
            controller: logic.controller,
            focusNode: _focusNode,
          ),
          MGCard(
            margin: EdgeInsets.only(top: 10, left: 16, right: 16),
            children: [
              MGItems(
                leadTitle: "手续费",
                trailingWidget: Obx(() => Text.rich(TextSpan(children: [
                      TextSpan(
                        text: logic.serverMonry.value,
                        style: TextStyle(
                          fontSize: MGFont.textFont2,
                          color: MGColors.text1Color,
                        ),
                      ),
                      TextSpan(
                        text: "(${(logic.userInfoLogic.userInfo.withdrawFeeRate ?? 0.00) * 100}%)",
                        style: TextStyle(
                          fontSize: MGFont.textFont2,
                          color: MGColors.redColor,
                        ),
                      ),
                    ]))),
                showBottomSplit: true,
              ),
              MGItems(
                leadTitle: "到账金额",
                trailingWidget: Obx(() => Text(
                      logic.inComeMonry.value,
                      style: TextStyle(
                        fontSize: MGFont.textFont2,
                        color: MGColors.text1Color,
                      ),
                    )),
              )
            ],
          ),
          MGCard(
            margin: EdgeInsets.only(top: 10, left: 16, right: 16),
            children: [
              MGItems(
                leadTitle: "提现信息",
                leadStyle: TextStyle(
                  fontSize: MGFont.titleFont4,
                  color: MGColors.text1Color,
                  fontWeight: FontWeight.bold,
                ),
                showBottomSplit: true,
              ),
              MGItems(
                leadTitle: "手机号",
                trailingTitle: logic.userInfoLogic.userInfo.bankAccount?.reservedPhoneNumber,
                showBottomSplit: true,
              ),
              MGItems(
                leadTitle: "银行卡号",
                trailingTitle: logic.userInfoLogic.userInfo.bankAccount?.bankCardNumber,
              )
            ],
          )
        ],
      ),
      bottomNavigationBar: MGButton(
        title: "确定",
        padding: EdgeInsets.only(left: 30, right: 30, bottom: 30, top: 15),
        buttonAction: logic.sureAction,
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<AccountWithdrawAmountLogic>();
    super.dispose();
  }
}
